﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Fastyou.WCF.Contracts;
using Fastyou.DesignPattern.FactoryMethod;
using Fastyou.Other.Consoles.LINQ;
using Fastyou.Other.Consoles.Interfaces;
using Fastyou.DesignPattern.Decorator;
using Fastyou.DesignPattern.Bridge;

namespace Fastyou.Other.Consoles
{
    class A
    {
        public static int X;
        static A()
        {
            X = Program.Y + 1;
        }
    }

    class Program
    {

        static void Main()
        {
            //DPTest();
            //YieldTest();
            //Linq2objTest();
            //Linq2XmlTest();
            //Fastyou.Other.Consoles.LINQ.LINQ2Other.WriteDirToXML();
            //Console.WriteLine("X={0},Y={1}", A.X, Program.Y);
            //Lambda.writestr();
            //Operatorscs.OperatorA(2, 4);
            //InterfaceTest();
            DesignP();
            Console.ReadLine();
        }

        private static void DesignP()
        {
            Colors color = new RedLight();
            color.Light = new RectLight();
            color.TurnOn();

            //color.Light = new BallLight();
            //color.TurnOn();

            //IFan fan = new BoxFan();
            //fan.On();
            //IFan fann = (new DecoFan(fan));
            //fann.On();
            //fann.Off();
        }
        private static void InterfaceTest()
        {
            IDoor door = new GateDoor();
            door.Open();
            door.Close();

            door = new WoodGateDoor();
            door.Close();
            door.Open();

            GateDoor gd = new WoodGateDoor();
            gd.Open();


            WoodGateDoor wgd = new WoodGateDoor();
            wgd.Open();
            wgd.Close();
        }

        private static void Linq2XmlTest()
        {
            Linq2XML lxml = new Linq2XML();
            lxml.GetAttributes();
            //lxml.CreateXml();
            //lxml.CreateLinqXmlElement();
            //lxml.CreateXmlElement();
        }

        private static void Linq2objTest()
        {
            LINQ2Objects lt = new LINQ2Objects();
            IList<int> s = lt.GetTestStr();
            foreach (var i in s)
            {
                Console.WriteLine(i.ToString());
            }
        }
        private static void YieldTest()
        {
            Yield yd = new Yield();
            foreach (int i in yd.Getyidld(2,8))
            {
                Console.Write(i.ToString()+"\r\n");
            }
        }
        private static void DPTest()
        {
            Factory factory1 = new TextFactory();
            Factory factory2 = new CommentFactory();

            Question q1 = factory1.Create();
            Console.Write(q1.Display);

            Question q2 = factory2.Create();
            Console.Write(q2.Display);
        }

        public static int Y = A.X + 1;
        static Program() { }

        public void ninetable()
        {
            Console.Write("请输入行数:");
            int lines = int.Parse(Console.ReadLine());
            Console.WriteLine("");

            StringBuilder sb = new StringBuilder();

            for (int i = 1; i <= lines; i++)
            {
                sb.Append(' ', lines - i);
                sb.Append('*', i * 2 - 1);
                Console.WriteLine(sb.ToString());
                sb.Remove(0, sb.Length);
            }
        }
        //static void Main(string[] args)
        //{
        //    //#region Hello

        //    ////ChannelFactory<IHello> cf = new ChannelFactory<IHello>("BasicHttpBinding_IHello");
        //    ////IHello he = cf.CreateChannel();
        //    ////he.SayHello("laihua.");

        //    //#endregion

        //    //#region ConSingleMode

        //    //ChannelFactory<ISingleMode> cf = new ChannelFactory<ISingleMode>("WSHttpBinding_ISignleMode");
        //    //ISingleMode sm = cf.CreateChannel();
        //    //sm.Add(1, 2);
        //    //sm.Sub(3, 4);
        //    ////ISingleMode sm1 = cf.CreateChannel();
        //    ////sm1.Sub(3, 4);
        //    //#endregion

        //    //#region AsyncInvoke

        //    ////AsyncInvoke ai = new AsyncInvoke();
        //    ////AsyncDelegate ad = new AsyncDelegate(ai.DoAsyncEvent);
        //    ////IAsyncResult ia = ad.BeginInvoke(DateTime.Now, null, null);
        //    ////ai.DoSyncEvent(DateTime.Now);
        //    ////ad.EndInvoke(ia);
        //    ////Console.WriteLine(string.Format("adfadfa,time is {0}.", DateTime.Now.ToString()));
        //    ////Console.ReadLine();

        //    //#endregion

        //    Console.ReadLine();

        //}
    }
}